home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / dev / src / rot3dsrc.lha / rot3d / megadraw.a < prev    next >
Encoding:
Text File  |  1994-04-11  |  2.8 KB  |  153 lines

  1. ;/****************************************************************
  2. ;This code is copyright 1993. All Rights Reserved. Authors:-
  3. ;
  4. ;  Jason Freund and Gabe Dalbec.
  5. ;  Chris Hames
  6. ;
  7. ;****************************************************************/
  8.  
  9. ;This is the core of the program.  It takes a column from the
  10. ;source bitmap and shrinks/expands and copies it to the fastram offscreen
  11. ;bitmap.
  12.  
  13. ;This cannot be sped up because we spent 75% of the time of the development
  14. ;of the entire program in this file.
  15.  
  16. ;    INCLUDE "defines.i"
  17.  
  18.  
  19.     section    data
  20.  
  21.     XDEF    _mdtmps
  22.  
  23. _mdtmps:
  24.  
  25. sbit:    EQU 0
  26.     dc.l    0
  27. sbitn:    EQU 4
  28.     dc.l    0
  29. dbitn:    EQU 8
  30.     dc.l    0
  31. roff:    EQU 12
  32.     dc.l    0
  33. dbpr:    EQU 16
  34.     dc.l    0
  35. sy:    EQU 20
  36.     dc.l    0
  37.  
  38.     section    code
  39.  
  40.     XDEF    _Fill
  41.  
  42.     XREF    _rowlook
  43.     XREF    _map
  44.     XREF    _fastbm
  45.     XREF    _brushmem
  46.     XREF    _lightcolor
  47.     XREF    _lighttable
  48.  
  49. _Fill:
  50.     movem.l    d2-d7/a2-a6,-(sp)
  51.     lea    _fastbm,a5            ; get dst bitmap pointer
  52.     lea    _map,a6                ; get address of map struct
  53.     lea    _mdtmps,a3
  54.  
  55.     moveq    #0,d0
  56.     move.w    (a5),d0            ; BytesPerRow
  57.     lsl.w    #3,d0
  58.     subq.w    #1,d0            ; for i=SCREENX to 0
  59.  
  60.     move.w    d0,d3
  61.     lsl.w    #3,d3
  62.     add.w    d3,a6
  63.  
  64. filoop:
  65.     move.w    (a6)+,d6        ; get map[i].height
  66.     move.w    (a6)+,d4        ; get bitmap no
  67.     move.w    (a6)+,d2        ; get offset
  68.     lsl.w    #2,d4            ; for long word pointer
  69.     lea     _lightcolor,a1
  70.     moveq.l #0,d3
  71.     move.b  (a1,d0.w),d3
  72.     lea        _brushmem,a2
  73.     move.l    0(a2,d4.w),a1    ;  get pointer to brush
  74.     movea.l _lighttable,a2
  75.     lsl.l   #6,d3
  76.     add.l   d3,a2
  77.     asr.w    #6,d6
  78.     move.w    d6,sy(a3)
  79.     bge.s    pastneg
  80.     moveq    #0,d6
  81.  
  82. pastneg:
  83.     move.w    d0,-(sp)        ; save i counter
  84. MegaDraw:
  85.     move.w    d0,d4
  86.     and.w    #7,d4
  87.     moveq    #7,d3
  88.     sub.w    d4,d3
  89.     move.b    d3,d5            ; d5<-dbitn=(7-sx&7)
  90.  
  91.     add.w    d2,a1
  92.  
  93.     move.w    d0,d3
  94.     lsr.w    #3,d3
  95.     lsl.w    #2,d3            ; d3<-rsx=sx/8 * 4
  96.  
  97.     move.w    (a5),d1            ; d1<-dbrp=bitmap->BytesPerRow
  98.  
  99.     move.w    d1,d7
  100.     lsl.w    #2,d1
  101.     muls.w    d6,d1
  102.     add.w    d3,d1            ; d1<-dplus
  103.  
  104.     move.l    8(a5),a4        ; a4<-dptr=bitmap->Planes[0]+dplus
  105.     adda.l    d1,a4
  106.     move.w    d7,d1
  107.     move.b    d5,d4
  108.  
  109.     move.l    _rowlook,a0
  110.     move.w    sy(a3),d7        ; d7<-sy
  111.     muls.w    #1024,d7        ; d7<-sy*1024   256 longs
  112.     move.w    2(a5),d0        ; d0<-dst->Rows
  113.     mulu.w    #1536,d0        ; d0<-rows*1200
  114.     add.l    d0,d7            ; d7<-rows*1200+sy*1024
  115.     adda.l    d7,a0            ; a0<-_rowlook+rows*1200+sy*1024
  116.  
  117.     move.w    d6,d7            ;
  118.     lsl.w    #2,d7
  119.     adda.w  d7,a0
  120.     move.l    (a0)+,d0
  121.     lsl.l    #2,d1
  122.  
  123.     moveq   #0,d7
  124.     move.w  2(a5),d5
  125.     lsr.w   #1,d5            ; d5<-rows/2
  126.     sub.w   d6,d5
  127.     cmp.w   #0,d5
  128.     ble.s   pastiloop
  129.     subq.w  #1,d5
  130.     lsl.w   #1,d5            ; do loop twice as long for top to bottom rather than half
  131.  
  132.     lsl.w   #5,d4            ; step into shifted lighttable
  133.     lsl.w   #5,d4            ; dbitn*1024 to get to correct lighttable
  134.     add.w   d4,a2
  135.  
  136. iloop:
  137.     move.b  0(a1,d0.l),d7    ; get planes for bit
  138.     move.l  0(a2,d7.w),d2   ; look up in colortable
  139.     or.l    d2,(a4)
  140.     adda.l    d1,a4            ; d1 dplus+=dbrp
  141.     move.l    (a0)+,d0        ; use lookup to calculate row
  142.     dbra.w  d5,iloop
  143.  
  144. pastiloop:
  145.     move.w    (sp)+,d0        ; get i counter
  146. past1:
  147.     suba.w    #8+6,a6
  148.     dbra.w    d0,filoop
  149.  
  150.     movem.l    (sp)+,d2-d7/a2-a6
  151.     rts
  152.  
  153.